package com.humngyang.com.hmy.controller;

import com.humngyang.com.hmy.entity.Authority;
import com.humngyang.com.hmy.service.AuthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@CrossOrigin
@RestController
@RequestMapping("/AuthorityController")
public class AuthorityController {



    @Autowired
    AuthorityService authorityService;

    /**
     * Author : hmy
     * @date 2020/2/25 22:11
     * describution : 查询所有的权限列表
     **/

    @RequestMapping("/getAllAuthrority")
    public Map<String,Object> getAllAuthrority(){
        Map<String,Object> re = new HashMap<>();
        List<Authority> allAuthrority = authorityService.getAllAuthrority();
        re.put("flag",1);
        re.put("list",allAuthrority);
        return re;
    }

    @RequestMapping("/getTreeAuthrority")
    public Map<String,Object> getTreeAuthrority(){
        Map<String,Object> re = new HashMap<>();
        List<Map<String,Object>> treeAuthrority = authorityService.getTreeAuthrority();
        re.put("flag",1);
        re.put("list",treeAuthrority);
        return re;
    }



}
